package com.rati.usercenter.once;

import com.rati.usercenter.mapper.UserMapper;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;

import javax.annotation.Resource;

/**
 * 批量插入用户
 *
 * @author Lwh
 * @time 2022/12/21 11:51
 */
@Component
public class InsertUsers {

    @Resource
    private UserMapper userMapper;

//    @Scheduled(initialDelay = 1000, fixedRate = Long.MAX_VALUE)
    public void doInsert() {
        StopWatch stopWatch = new StopWatch();
        stopWatch.start();
        final int INSERT_NUM = 1000;
//        for (int i = 0; i < INSERT_NUM; i++) {
//            User user = new User();
//            user.setUsername("fakeUser");
//            user.setUserAccount("fakeUser");
//            user.setUserPassword("fakeUser");
//            user.setGender(0);
//            user.setPhone("12345678910");
//            user.setEmail("12345678910@email.com");
//            user.setUserStatus(0);
//            userMapper.insert(user);
//        }
        stopWatch.stop();
        System.out.println(stopWatch.getTotalTimeMillis());
    }

}
